from django.db import models
from userinfo.models import UserInfo

# Create your models here.

#博客信息
class BlogInfo(models.Model):
    Title = models.CharField(max_length=64)
    def __str__(self):
        return self.id


# 文章分类
class Category(models.Model):
    name = models.CharField(max_length=8,blank=True,null=True)
    belong = models.ForeignKey("self", on_delete=models.CASCADE,blank=True,null=True)
    def __str__(self):
        return str(self.id)


    class Meta:
        verbose_name = '分类'
        verbose_name_plural = verbose_name
# 文章
class Article(models.Model):
    Title = models.CharField(max_length=254)
    Cover = models.CharField(max_length=254)
    Text = models.TextField()
    Category = models.ForeignKey(Category,on_delete=models.CASCADE,blank=True,null=True)
    Belong = models.ForeignKey(UserInfo,on_delete=models.CASCADE,blank=True,null=True)
    def __str__(self):
        return self.id

    class Meta:
        verbose_name = '文章'
        verbose_name_plural = verbose_name

# 收藏
class Favourite(models.Model):
    belong_user = models.ForeignKey(UserInfo, on_delete=models.CASCADE)
    belong_art = models.ForeignKey(Article, on_delete=models.CASCADE)
    def __str__(self):
        return self.id

    class Meta:
        verbose_name = '收藏'
        verbose_name_plural = verbose_name


# 点赞
class Like(models.Model):
    belong_user = models.ForeignKey(UserInfo, on_delete=models.CASCADE)
    belong_art = models.ForeignKey(Article, on_delete=models.CASCADE)
    def __str__(self):
        return self.id

    class Meta:
        verbose_name = '点赞'
        verbose_name_plural = verbose_name

#打赏
class PayOrder(models.Model):
    order = models.CharField(max_length=256)
    price = models.CharField(max_length=16)
    status = models.BooleanField()
    def __str__(self):
        return self.id


    class Meta:
        verbose_name = '打赏'
        verbose_name_plural = verbose_name